package com.jiyun.h2303b.controller;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.jiyun.h2303b.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("business")
public class BusinessController {

    @Autowired
    private BusinessService businessService;

    @RequestMapping("buy")
    public void buy(int userId,String commodity_code,int count){
        businessService.buy(userId, commodity_code, count);
    }

//    @SentinelResource()
    @RequestMapping("brand")
    public void brand(){
        businessService.changeBrand();
    }

    @SentinelResource(value = "MyTest",blockHandler = "TestBlockHandler")
    @RequestMapping("test")
    public String test(){
        return "test";
    }


    public String TestBlockHandler(BlockException blockException){
        return "被流控了";
    }
}
